package com.wzdigit.wms.basic.enums;

import java.util.Objects;

/**
 * 收货单SN操作标识
 * Created by zyf on 2021/9/8 12:09
 */
public enum AsnOpFlagEnum implements BaseEnum {

    INSERT("INSERT", "INSERT", "新增"),
    UPDATE("UPDATE", "UPDATE", "修改");

    public String code;

    /**
     * 枚举名称
     */
    public String enumName;

    /**
     * 枚举实体类属性描述
     */
    public String description;

    AsnOpFlagEnum(String enumName, String description) {
        this.enumName = enumName;
        this.description = description;
    }

    AsnOpFlagEnum(String code, String enumName, String description) {
        this.code = code;
        this.enumName = enumName;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getEnumName() {
        return enumName;
    }

    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public static AsnOpFlagEnum getEnumByCode(String enumCode) {
        AsnOpFlagEnum[] values = AsnOpFlagEnum.values();
        AsnOpFlagEnum samplingEnum = null;

        for (AsnOpFlagEnum value : values) {
            if (value.getCode().equals(enumCode)) {
                samplingEnum = value;
                break;
            }
        }
        return samplingEnum;
    }

    public static AsnOpFlagEnum getEnumByName(String enumName) {
        AsnOpFlagEnum[] values = AsnOpFlagEnum.values();
        AsnOpFlagEnum repairEnum = null;

        for (AsnOpFlagEnum value : values) {
            if (value.getEnumName() == enumName) {
                repairEnum = value;
            }
        }
        return repairEnum;
    }

    public static String getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
        AsnOpFlagEnum[] values = AsnOpFlagEnum.values();
        for (AsnOpFlagEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)
                    && Objects.equals(value.getEnumName(), enumName)) {
                return value.getCode();
            }
        }
        return null;
    }

}
